package com.hackaton.touringengine;

import java.io.IOException;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hackaton.touringengine.entity.Location;
import com.hackaton.touringengine.entity.User;
import com.hackaton.touringengine.persistence.PersistenceFactory;

public class DeleteDataServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1716205233817273339L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		PersistenceManager pm = PersistenceFactory.get().getPersistenceManager();
		try {
		    Query query = pm.newQuery(Location.class);
		    List<Location> locations = (List<Location>)query.execute();
		    for (Location location : locations) {
		    	pm.deletePersistent(location);
		    }
		} finally {
			pm.close();
		}
	}


}
